﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kokomo.NeuralNets
{
	public class Node
	{
		public double[] IncomingWeights { get; private set; }

		public Node(int inputCount)
		{
			this.IncomingWeights = new double[inputCount];
		}

		protected void ValidateInputVector(double[] inputVector)
		{
			ArgumentValidation.CheckNullArgument("inputVector", inputVector);
			if (inputVector.Length != this.IncomingWeights.Length)
			{
				throw new ArgumentException("Incorrect sized inputVector", "inputVector");
			}
		}

		public static double Sigmoid(double t)
		{
			return 1.0 / (1 + Math.Exp(-t));
		}
		public double Activate(double[] inputVector)
		{
			this.ValidateInputVector(inputVector);

			double acc = 0;
			for (int i = 0; i < inputVector.Length; i++)
			{
				double input = inputVector[0];
				double weight = this.IncomingWeights[i];

				acc += input * weight;
			}

			double z = Sigmoid(acc);

			return z;
		}
	}
}
